package com.wolfking.config;

import com.wolfking.converter.config.DynamicDataSourceContext;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

public class DynamicDataSource extends AbstractRoutingDataSource {

    private final DynamicDataSourceContext dataSourceContext;

    public DynamicDataSource(DynamicDataSourceContext dataSourceContext) {
        this.dataSourceContext = dataSourceContext;
    }

    @Override
    protected Object determineCurrentLookupKey() {
        return dataSourceContext.getDataSourceType();
    }
}
